package leaveSystem.model;

import java.io.Serializable;
import java.util.Date;

public class Leave implements Cloneable, Serializable {

    private int leaveId;
    private int leaveTypeId;
    private int employeeId;
    private Date leaveStartDate;
    private Date leaveEndDate;
   	private String leaveReason;
    private String status;
    private String remarks;
    private int remainingLeaves;
    private String createdBy;
    private Date createdOn;
    private String modifiedBy;
    private Date modifiedOn;



    /** 
     * Constructors. DaoGen generates two constructors by default.
     * The first one takes no arguments and provides the most simple
     * way to create object instance. The another one takes one
     * argument, which is the primary key of the corresponding table.
     */

    public Leave () {

    }

    public Leave (int leaveIdIn) {

          this.leaveId = leaveIdIn;

    }


    /** 
     * Get- and Set-methods for persistent variables. The default
     * behaviour does not make any checks against malformed data,
     * so these might require some manual additions.
     */
    public Date getLeaveStartDate() {
		return leaveStartDate;
	}

	public void setLeaveStartDate(Date leaveStartDate) {
		this.leaveStartDate = leaveStartDate;
	}

	public Date getLeaveEndDate() {
		return leaveEndDate;
	}

	public void setLeaveEndDate(Date leaveEndDate) {
		this.leaveEndDate = leaveEndDate;
	}
    public int getLeaveId() {
          return this.leaveId;
    }
    public void setLeaveId(int leaveIdIn) {
          this.leaveId = leaveIdIn;
    }

    public int getLeaveTypeId() {
          return this.leaveTypeId;
    }
    public void setLeaveTypeId(int leaveTypeIdIn) {
          this.leaveTypeId = leaveTypeIdIn;
    }

    public int getEmployeeId() {
          return this.employeeId;
    }
    public void setEmployeeId(int employeeIdIn) {
          this.employeeId = employeeIdIn;
    }

      public String getLeaveReason() {
          return this.leaveReason;
    }
    public void setLeaveReason(String leaveReasonIn) {
          this.leaveReason = leaveReasonIn;
    }

    public String getStatus() {
          return this.status;
    }
    public void setStatus(String statusIn) {
          this.status = statusIn;
    }

    public String getRemarks() {
          return this.remarks;
    }
    public void setRemarks(String remarksIn) {
          this.remarks = remarksIn;
    }

    public int getRemainingLeaves() {
          return this.remainingLeaves;
    }
    public void setRemainingLeaves(int remainingLeavesIn) {
          this.remainingLeaves = remainingLeavesIn;
    }

    public String getCreatedBy() {
          return this.createdBy;
    }
    public void setCreatedBy(String createdByIn) {
          this.createdBy = createdByIn;
    }

    public Date getCreatedOn() {
          return this.createdOn;
    }
    public void setCreatedOn(Date createdOnIn) {
          this.createdOn = createdOnIn;
    }

    public String getModifiedBy() {
          return this.modifiedBy;
    }
    public void setModifiedBy(String modifiedByIn) {
          this.modifiedBy = modifiedByIn;
    }

    public Date getModifiedOn() {
          return this.modifiedOn;
    }
    public void setModifiedOn(Date modifiedOnIn) {
          this.modifiedOn = modifiedOnIn;
    }



    /** 
     * setAll allows to set all persistent variables in one method call.
     * This is useful, when all data is available and it is needed to 
     * set the initial state of this object. Note that this method will
     * directly modify instance variales, without going trough the 
     * individual set-methods.
     */

    public void setAll(int leaveIdIn,
          int leaveTypeIdIn,
          int employeeIdIn,
          java.sql.Date leaveStartDateIn,
          java.sql.Date leaveEndDateIn,
          String leaveReasonIn,
          String statusIn,
          String remarksIn,
          int remainingLeavesIn,
          String createdByIn,
          Date createdOnIn,
          String modifiedByIn,
          Date modifiedOnIn) {
          this.leaveId = leaveIdIn;
          this.leaveTypeId = leaveTypeIdIn;
          this.employeeId = employeeIdIn;
          this.leaveStartDate = leaveStartDateIn;
          this.leaveEndDate = leaveEndDateIn;
          this.leaveReason = leaveReasonIn;
          this.status = statusIn;
          this.remarks = remarksIn;
          this.remainingLeaves = remainingLeavesIn;
          this.createdBy = createdByIn;
          this.createdOn = createdOnIn;
          this.modifiedBy = modifiedByIn;
          this.modifiedOn = modifiedOnIn;
    }

    public boolean hasEqualMapping(Leave valueObject) {

          if (valueObject.getLeaveId() != this.leaveId) {
                    return(false);
          }
          if (valueObject.getLeaveTypeId() != this.leaveTypeId) {
                    return(false);
          }
          if (valueObject.getEmployeeId() != this.employeeId) {
                    return(false);
          }
          if (this.leaveStartDate == null) {
                    if (valueObject.getLeaveStartDate() != null)
                           return(false);
          } else if (!this.leaveStartDate.equals(valueObject.getLeaveStartDate())) {
                    return(false);
          }
          if (this.leaveEndDate == null) {
                    if (valueObject.getLeaveEndDate() != null)
                           return(false);
          } else if (!this.leaveEndDate.equals(valueObject.getLeaveEndDate())) {
                    return(false);
          }
          if (this.leaveReason == null) {
                    if (valueObject.getLeaveReason() != null)
                           return(false);
          } else if (!this.leaveReason.equals(valueObject.getLeaveReason())) {
                    return(false);
          }
          if (this.status == null) {
                    if (valueObject.getStatus() != null)
                           return(false);
          } else if (!this.status.equals(valueObject.getStatus())) {
                    return(false);
          }
          if (this.remarks == null) {
                    if (valueObject.getRemarks() != null)
                           return(false);
          } else if (!this.remarks.equals(valueObject.getRemarks())) {
                    return(false);
          }
          if (valueObject.getRemainingLeaves() != this.remainingLeaves) {
                    return(false);
          }
          if (this.createdBy == null) {
                    if (valueObject.getCreatedBy() != null)
                           return(false);
          } else if (!this.createdBy.equals(valueObject.getCreatedBy())) {
                    return(false);
          }
          if (this.createdOn == null) {
                    if (valueObject.getCreatedOn() != null)
                           return(false);
          } else if (!this.createdOn.equals(valueObject.getCreatedOn())) {
                    return(false);
          }
          if (this.modifiedBy == null) {
                    if (valueObject.getModifiedBy() != null)
                           return(false);
          } else if (!this.modifiedBy.equals(valueObject.getModifiedBy())) {
                    return(false);
          }
          if (this.modifiedOn == null) {
                    if (valueObject.getModifiedOn() != null)
                           return(false);
          } else if (!this.modifiedOn.equals(valueObject.getModifiedOn())) {
                    return(false);
          }

          return true;
    }



    /**
     * toString will return String object representing the state of this 
     * valueObject. This is useful during application development, and 
     * possibly when application is writing object states in textlog.
     */
    public String toString() {
        StringBuffer out = new StringBuffer(this.getDaogenVersion());
        out.append("\nclass Leave, mapping to table leave\n");
        out.append("Persistent attributes: \n"); 
        out.append("leaveId = " + this.leaveId + "\n"); 
        out.append("leaveTypeId = " + this.leaveTypeId + "\n"); 
        out.append("employeeId = " + this.employeeId + "\n"); 
        out.append("leaveStartDate = " + this.leaveStartDate + "\n"); 
        out.append("leaveEndDate = " + this.leaveEndDate + "\n"); 
        out.append("leaveReason = " + this.leaveReason + "\n"); 
        out.append("status = " + this.status + "\n"); 
        out.append("remarks = " + this.remarks + "\n"); 
        out.append("remainingLeaves = " + this.remainingLeaves + "\n"); 
        out.append("createdBy = " + this.createdBy + "\n"); 
        out.append("createdOn = " + this.createdOn + "\n"); 
        out.append("modifiedBy = " + this.modifiedBy + "\n"); 
        out.append("modifiedOn = " + this.modifiedOn + "\n"); 
        return out.toString();
    }


    /**
     * Clone will return identical deep copy of this valueObject.
     * Note, that this method is different than the clone() which
     * is defined in java.lang.Object. Here, the retuned cloned object
     * will also have all its attributes cloned.
     */
    public Object clone() {
        Leave cloned = new Leave();

        cloned.setLeaveId(this.leaveId); 
        cloned.setLeaveTypeId(this.leaveTypeId); 
        cloned.setEmployeeId(this.employeeId); 
        if (this.leaveStartDate != null)
             cloned.setLeaveStartDate((java.sql.Date)this.leaveStartDate.clone()); 
        if (this.leaveEndDate != null)
             cloned.setLeaveEndDate((java.sql.Date)this.leaveEndDate.clone()); 
        if (this.leaveReason != null)
             cloned.setLeaveReason(new String(this.leaveReason)); 
        if (this.status != null)
             cloned.setStatus(new String(this.status)); 
        if (this.remarks != null)
             cloned.setRemarks(new String(this.remarks)); 
        cloned.setRemainingLeaves(this.remainingLeaves); 
        if (this.createdBy != null)
             cloned.setCreatedBy(new String(this.createdBy)); 
        if (this.createdOn != null)
             cloned.setCreatedOn((Date)this.createdOn.clone()); 
        if (this.modifiedBy != null)
             cloned.setModifiedBy(new String(this.modifiedBy)); 
        if (this.modifiedOn != null)
             cloned.setModifiedOn((Date)this.modifiedOn.clone()); 
        return cloned;
    }



    /** 
     * getDaogenVersion will return information about
     * generator which created these sources.
     */
    public String getDaogenVersion() {
        return "DaoGen version 2.4.1";
    }

}
